package com.heima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.heima.dto.pagedto.PageDto;
import com.heima.entity.Notice;
import com.heima.mapper.NoticeMapper;
import com.heima.result.PageResult;
import com.heima.service.NoticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class NoticeServiceImpl implements NoticeService {
    private final NoticeMapper noticeMapper;

    @Override
    public PageResult pageQuery(Integer status) {
        PageDto pageDto = new PageDto();
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<Notice> page = (Page<Notice>) noticeMapper.pageQuery(status);
        PageResult pageResult = new PageResult();
        pageResult.setTotal(page.getTotal());
        pageResult.setRows(page.getResult());
        return pageResult;
    }
}
